<%@page import="com.wodwl.entity.Category"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.wodwl.entity.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<%@include file="../templete/head.jsp"  %>
	<style type="text/css">
		.mainRight .btn{
			float: right;
			margin-right: 5px;
		}
		.content{
			margin-top: 5px;
		}
		.conbar{
			font-size: 16px;
			padding-left: 20px;
		}
		.list ul{
			list-style-type: none;
			display: block;
		}
		.list ul li{
			height: 30px;
			
		}
		.list span{
			display:inline-block;
			margin-right: 10px;
		}
		.category_add_btn{
			font-size: 10px;
		}
		
	</style>
</head>
<body >
	<%pageContext.setAttribute("linkType", "6");%>
	<%@include file="../templete/banner.jsp"  %>
	<% List<Category> categories=(List<Category>) request.getAttribute("categories");%>
		
		
	
	<div class="mainRight">
		<div class="mainRightBar">
				<div class="title">博客分类</div>
				<div class="myblog_btn btn" >我的博客</div>
				<div class="blog_category_btn btn">博客分类</div>
				<div class="blog_list_btn btn" >博客列表</div>
				<div class="write_blog_btn btn" >写博客</div>
		</div>
		<div class="content">
			<div class="conbar">
				<form action="/blog/category_add.do" method="post" class="myform">
					添加分类：<input type="text" name="cname" >
					<span class="category_add_btn">提交</span>
				</form>
			</div>	
			<div class="list">
				<ul>	
					<%
						if(categories!=null)
						for (int i = 0; i < categories.size(); i++) {
							Category item = categories.get(i);
					%>

							<li>
								<span>
									<span id="c<%=i%>"><%=item.getCname() %></span>&nbsp;&nbsp;&nbsp;&nbsp;
									共<%=item.getCount() %>篇博客
								</span>
								<span>
									<a onclick="modify('c<%=i%>','<%=item.getCid()%>')" href="#">修改</a>
									<a  onclick="del('c<%=i%>','<%=item.getCid()%>')" href="#">删除</a>
								</span>
							</li>
					<%}%>		
				</ul>	
			</div>
		</div>

	</div>
</div>

<%@include file="../templete/footer.jsp"  %>
	
<script type="text/javascript">
$(document).ready(function(){
	$(".btn").button();
	$(".category_add_btn").button();

	$(".write_blog_btn").click(function(){
		window.location.href="/blog/blog_add_view.do";
	});
	$(".blog_list_btn").click(function(){
		window.location.href="/blog/blog_list.do";
	});
	$(".blog_category_btn").click(function(){
		window.location.href="/blog/category_list.do";
	});
	$(".myblog_btn").click(function(){
		window.location.href="#";
	});
	
	
	function modify(id,cid){
		var cname=$("#"+id).html();
		$("#"+id).html('<form action="/blog/category_modify.do" method="post" class="myform_'+cid+'">\
					<input type="hidden" name="cid" value="'+cid+'">\
					<input type="text" name="cname" value="'+cname+'">\
					<span class="rename_btn_'+cid+'">确定</span></form>');
		$(".rename_btn_"+cid).css("font-size","10px");
		$(".rename_btn_"+cid).button();
		$(".rename_btn_"+cid).click(function(){
			$(".myform_"+cid).submit();
		});
	}
	function del(id,cid){
		var item=document.getElementById(id);
		var cname=item.innerHTML
		if (confirm("您确定要删除分类"+cname))
			  window.location='/blog/category_delete.do?cid='+cid;
	}
	
});
</script>
</body>
</html>